package com.zj.juc.study.interrupted;

/**
 * @author 自己的名字
 * @version 1.0.0
 * @ClassName ThreadStaticInterruptedDemo
 * @Description 线程静态interruted
 * @createTime 2024年12月26日 22:12
 */
public class ThreadStaticInterruptedDemo {

    //Thread.interrupted:1.返回当前线程打断状态，2.将当前线程打断状态清零并重新设置为false,清除线程的中断状态
    public static void main(String[] args) {
        //最开始false
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());//返回false;当前线程打断状态清零并设置为false
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());//返回false;当前线程打断状态清零并设置为false
        System.out.println("1------");
        Thread.currentThread().interrupt();//中断标志位设置为true
        System.out.println("2-------");
        //返回true并将线程打断状态设置为false
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());
        //返回false并将当前线程打断状态设置为false
        System.out.println(Thread.currentThread().getName()+"\t"+Thread.interrupted());
    }
}
